<link href="https://cdn.bootcss.com/iCheck/1.0.2/skins/all.css" rel="stylesheet">
<link href="https://cdn.bootcss.com/iCheck/1.0.2/skins/square/blue.css" rel="stylesheet">
<div>
<table class="table table-striped">
    <thead>
        <tr>
            <th>状态</th>
            <th>计划</th>
        </tr>
    </thead>
    <tbody>
        {php}
        $i=0;
        {/php}
        {foreach name="plan_list" item="vo" key = "level"}
        <tr>
            <!--<th scope="row">{$i|default='无'}</th>-->
            <td><input type="checkbox" name="iCheck" data-id="{$vo.id|default='无'}"></td>
            <td>{$vo.plan_str|default=''}</td>
        </tr>
        {/foreach}
    </tbody>
</table>
</div>
<div class="row">
    <div class="col-xs-offset-8 col-xs-4">
        <button type="button" class="btn btn-primary" onclick="location.href = '{:merge_url('add_plan');}' ">添加</button>
    </div>
</div>
<script src="https://cdn.bootcss.com/iCheck/1.0.2/icheck.js"></script>
<script>
    $(function($){
        $('input').iCheck({
            checkboxClass: 'iradio_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '50%' // optional
        });
        $('input').on('ifChecked', function(event){
                        let url = "{:merge_url('');}"
                        let data =  {id:$(this).data('id')};
                        //添加划线
                        $(this).closest('td').next('td').wrapInner("<del></del>");
                        $.post (url, data, function (res)
                        {
                            if (res.code)
                            {
                            }
                        });
          });
        $('input').on('ifUnchecked', function(event){
                        let url = "{:merge_url('');}"
                        let data = {id:$(this).data('id')};
                        //祛除划线
                        let ele_td = $(this).closest('td').next('td')
                        let text = ele_td.children().html();
                       ele_td.html(text);
                        $.post (url, data, function (res)
                        {
                            if (res.code)
                            {
                            }
                        });
          });
    });
    
            function error_layer (msg)
        {
            layer.open ({
                title: '错误提示',
                icon: 2,
                content: msg,
                yes: function ()
                {
                    layer.closeAll ();
                }
            });
        }

        function success_layer (msg)
        {
            layer.open ({
                title: '成功提示',
                icon: 1,
                content: msg,
                yes: function ()
                {
                    layer.closeAll ();
                }
            });
        }
</script>